package com.example.wjh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.wjh.entity.PlayerData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PlayerDataMapper extends BaseMapper<PlayerData> {
    @Select("<script> " +
            "SELECT * FROM playerdata " +
            "<where> " +
            "<if test='name != null'> AND name LIKE CONCAT('%', #{name}, '%')</if> " +
            "<if test='threepoint != null'> AND CAST(threepoint AS UNSIGNED)  &gt;= #{threepoint}</if> " +
            "<if test='offense != null'> AND CAST(offense AS UNSIGNED)  &gt;= #{offense}</if> " +
            "<if test='defense != null'> AND CAST(defense AS UNSIGNED)  &gt;= #{defense}</if> " +
            "<if test='position != null'> AND position = #{position}</if> " +
            "</where> " +
            "</script>")
    List<PlayerData> searchPlayerdata(
            @Param("name") String name,
            @Param("threepoint") String threepoint,
            @Param("offense") String offense,
            @Param("defense") String defense,
            @Param("position") String position);
}

